local xuqi = fk.CreateSkill{
  name = "wk_heg__xuqi",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["wk_heg__xuqi"] = "虚栖",
  [":wk_heg__xuqi"] = "锁定技，①当你进入濒死状态被救回后，调离你至本回合结束；②你攻击范围内的角色视为处于所有与你势力相同角色的攻击范围内。",

  ["$wk_heg__xuqi1"] = "不若先行退避，再做打算。",
  ["$wk_heg__xuqi2"] = "敌势汹汹，不宜与其交锋。",
}

local H = require "packages/ol_hegemony/util"

xuqi:addEffect(fk.AfterDying, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(xuqi.name) and player == target
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(target, "@@lure_tiger-turn", 1)
    room:setPlayerMark(target, MarkEnum.PlayerRemoved .. "-turn", 1)
    room.logic:trigger(H.PlayerRemoved, target, {who = target}) -- FIXME
  end,
})

xuqi:addEffect("atkrange", {
  within_func = function (self, from, to)
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:hasSkill(xuqi.name) and from ~= p and H.compareKingdomWith(from, p) and p:inMyAttackRange(to) then
        return true
      end
    end
  end,
})

return xuqi